package com.cheetah.start.module.system.service.impl;

import com.cheetah.start.common.base.result.ResultData;
import com.cheetah.start.module.system.async.FileAsyncService;
import com.cheetah.start.module.system.domain.SysFile;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Feel
 * @date 2021/11/10 19:16
 * @Description:
 */
@Slf4j
@Service
public class CommonService {

    @Autowired
    private FileAsyncService fileAsyncService;

    /**
     * 异步记录文件信息
     */
    public void asyncRecord(SysFile sysFile) {
        fileAsyncService.record(sysFile);
    }

    public ResultData getResultData(SysFile sysFile) {
        ResultData res = new ResultData();
        res.put("full", sysFile.getFilePath())
                .put("half", sysFile.getFileUrl())
                .put("size", sysFile.getFileSize())
                .put("name", sysFile.getFileName());
        return res;
    }


}
